<template>
    <div v-loading="loading">
        <div class="title">
            <div>
                <span class="h1">业务管理</span>
                <span class="h2">客户业务记录</span>
            </div>
        </div>
        <div style="overflow: auto;padding-bottom: 100px;">
        <div class="sale-visiti">
            <div class="search">
                <span>回访记录：</span>
                <div style="width:240px;float:right;position: relative;">
                    <el-input v-model="input" placeholder="请输入..."></el-input>
                    <i class="el-icon-search" style="position: absolute; width:40px;height:36px;right:0;top:0;color:#000;text-align:center;line-height:36px"></i>
                </div>
            </div>
            <el-table :data="tableData1" style="width: 100%">
                <el-table-column prop="SalesName" label="业务员姓名">
                </el-table-column>
                <el-table-column prop="CustomerName" label="客户姓名">
                </el-table-column>
                <el-table-column prop="Visit_Time" label="回访时间">
                </el-table-column>
                <el-table-column prop="Visit_Content" label="回访内容">
                </el-table-column>
                <el-table-column prop="CreateMan" label="创建人">
                </el-table-column>
                <el-table-column prop="CreateDate" label="创建时间">
                </el-table-column>
            </el-table>
            <div style="float: right; margin-top: 10px;margin-right: 5px;">
                <el-pagination @current-change="handleCurrentChange" layout="prev, pager, next" :total="lengs">
                </el-pagination>
            </div>
        </div>
        <div class="sale-visiti">
            <div class="search">
                <span>到访记录：</span>
                <div style="width:240px;float:right;position: relative;">
                    <el-input v-model="input" placeholder="请输入..."></el-input>
                    <i class="el-icon-search" style="position: absolute; width:40px;height:36px;right:0;top:0;color:#000;text-align:center;line-height:36px"></i>
                </div>
            </div>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="ProjectName" label="项目名称">
                </el-table-column>
                <el-table-column prop="SalesName" label="业务员姓名">
                </el-table-column>
                <el-table-column prop="CustomerName" label="客户姓名">
                </el-table-column>
                <el-table-column prop="Visit_Time" label="创建时间">
                </el-table-column>
                <el-table-column prop="CreateMan" label="创建人">
                </el-table-column>
            </el-table>
            <div style="float: right; margin-top: 10px;margin-right: 5px;">
                <el-pagination @current-change="handleCurrentChange1" layout="prev, pager, next" :total="leng">
                </el-pagination>
            </div>
        </div>
        </div>
    </div>
</template>

<script>
	import api from '../../kits/api.js';
export default {
    name: 'salesMan',
    data() {
        return {
        	loading:true,
            input: '',
            tableData: [],
            lengs:1,
            tableData1: [],
            leng:1
        }
    },
    mounted: function() {
    	this.cusGetvisit()
    	this.cusGetsalevisit()
	},
    methods:{
    	handleCurrentChange(val){
    			this.loading = true
				console.log(`当前页: ${val}`);
				this.$axios.post(api.cusList, {
					"Para": {
						"ProjectIDs": [],
						"ListType": 1,
						"IsTrans": true,
						"KeyWord": ""
					},
					"PageSize": 10,
					"PageIndex": val-1,
					"OrderbyString": ""
				}).then((res) => {
					if(res.data.isOK) {
						console.log(res)
						this.tableData1 = res.data.data.Data
						this.lengs = res.data.data.Items || 1
						this.loading = false
					} else {
						if(res.data.msg == "Token无效" || res.data.msg == "Token缺失") {
							this.$router.push({
								path: '/login'
							})
						} else {
							this.loading = false
							this.$message.error(res.data.msg);
						}
					}
				});
    	},
    	handleCurrentChange1(val){
    			this.loading = true
				console.log(`当前页: ${val}`);
				this.$axios.post(api.cusList, {
					"Para": {
						"ProjectIDs": [],
						"ListType": 1,
						"IsTrans": true,
						"KeyWord": ""
					},
					"PageSize": 10,
					"PageIndex": val-1,
					"OrderbyString": ""
				}).then((res) => {
					if(res.data.isOK) {
						console.log(res)
						this.tableData = res.data.data.Data
						this.leng = res.data.data.Items || 1
						this.loading = false
					} else {
						if(res.data.msg == "Token无效" || res.data.msg == "Token缺失") {
							this.$router.push({
								path: '/login'
							})
						} else {
							this.loading = false
							this.$message.error(res.data.msg);
						}
					}
				});
    	},
    	//获取客户到访记录
    	cusGetvisit(){
    		this.loading =true
    		var me = this
			me.$axios.post(api.cusGetvisit, {
			  "Para": me.$route.params.id,
			  "PageSize": 10,
			  "PageIndex": 0,
			  "OrderbyString": "SalesName"
			}).then((res) => {
				if(res.data.isOK) {
					this.loading =false
					console.log(res)
					this.tableData = res.data.data.Data
					this.leng=res.data.data.Items||1
				} else {
					if(res.data.msg == "Token无效" || res.data.msg == "Token缺失") {
							this.$router.push({
								path: '/login'
							})
						} else {
							this.loading =false
							this.$message.error(res.data.msg);
						}
				}
			});
    	},
    	///获取客户的回访记录
    	cusGetsalevisit(){
    		this.loading =true
    		var me = this
			me.$axios.post(api.cusGetsalevisit, {
			  "Para": me.$route.params.id,
			  "PageSize": 10,
			  "PageIndex": 0,
			  "OrderbyString": "SalesName"
			}).then((res) => {
				if(res.data.isOK) {
					this.loading =false
					this.tableData1 = res.data.data.Data
					this.lengs=res.data.data.Items||1
					console.log(res)
				} else {
					if(res.data.msg == "Token无效" || res.data.msg == "Token缺失") {
							this.$router.push({
								path: '/login'
							})
						} else {
							this.loading =false
							this.$message.error(res.data.msg);
						}
				}
			});
    	}
    }
}
</script>

<style>
.title1 {
    width: 100%;
    padding: 15px;
    background: #fff;
    border-bottom: 1px solid #dddee1;
}

.title1 span {
    margin-right: 10px;
}

.title1 .h1 {
    font-size: 16px;
    font-weight: 600;
}

.title1 .h2 {
    font-size: 14px;
}

.search {
    width: 100%;
    height: 36px;
    line-height: 36px;
    margin-bottom: 10px
    /*border: 1px solid #000;*/
}

.search .ivu-input-icon {
    line-height: 36px;
}

.sale-visiti {
    margin-top: 10px;
}

.sale-visiti:after {
    display: block;
    clear: both;
    content: "";
    visibility: hidden;
    height: 0
}

.sale-page {
    float: right;
    margin-top: 15px;
}
</style>